package com.googlecode.tracey.messageserver;

import com.googlecode.funclate.stringtemplate.EnhancedStringTemplateGroup;
import com.googlecode.utterlyidle.MatchedResource;
import org.antlr.stringtemplate.StringTemplateGroup;

import java.net.URL;
import java.util.concurrent.Callable;

import static com.googlecode.totallylazy.URLs.packageUrl;

public class StringTemplateGroupActivator implements Callable<StringTemplateGroup> {
    private final URL baseUrl;

    public StringTemplateGroupActivator(final MatchedResource matchedResource) {
        this(packageUrl(matchedResource.forClass()));
    }

    private StringTemplateGroupActivator(URL baseUrl) {
        this.baseUrl = baseUrl;
    }

    public StringTemplateGroup call() throws Exception {
        return new EnhancedStringTemplateGroup(baseUrl);
    }

}
